<template>
  <div class="home">
    <h2>欢迎, {{ user.username }}</h2>
    <nav>
      <router-link to="/public-activities">公开活动列表</router-link>
      <router-link v-if="user.role === 'admin'" to="/activity-management">活动管理</router-link>
    </nav>
  </div>
</template>

<script>
export default {
  computed: {
  user() {
    const isAuthenticated = localStorage.getItem('user')
    return isAuthenticated ? JSON.parse(isAuthenticated) : null
  }
}
}
</script>

<style scoped>
.home {
  max-width: 800px;
  margin: 0 auto;
  padding: 20px;
}
nav a {
  margin-right: 15px;
  color: #42b983;
  text-decoration: none;
}
</style>